home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / c / metre.lha / metreint.h < prev    next >
C/C++ Source or Header  |  1994-09-07  |  6KB  |  160 lines

  1. /*************************************************************
  2.    Copyright (c) 1993,1994 by Paul Long  All rights reserved.
  3. **************************************************************/
  4.  
  5. /*************************************************************
  6.    metreint.h -   This header file contains #defines,
  7.                   typedefs, and externs that are used
  8.                   exclusively by the parser.  The rules
  9.                   code does not need access to these.
  10. **************************************************************/
  11.  
  12.  
  13. #ifndef _METREINT_H_
  14. #define _METREINT_H_
  15.  
  16. #include <string.h>
  17. #include <stddef.h>
  18. #include "metre.h"
  19.  
  20. #define metre_version   "1.08"
  21.  
  22.  
  23. /* General-purpose macros. */
  24. /*
  25.    Number of dimensions in array.  E.g., the following prints 10:
  26.       int a[10]; printf("%d\n", DIM_OF(a));
  27. */
  28. #define DIM_OF(x)    (sizeof (x) / sizeof (x[0]))
  29. /* Sets the object, x, to 0. */
  30. #define ZERO(x)      memset((void *)&x, 0, sizeof x)
  31.  
  32.  
  33. /*
  34.    This determines whether the input is buffered by reading in a line at a
  35.    time.  Set it to either TRUE or FALSE (1 or 0).  You can either do it here
  36.    or on the compilation command line, e.g., -DREAD_LINE=0.  The command
  37.    line takes precedence over whatever is specified here.
  38.  
  39.    There are two reasons why you might want to turn off input buffering.
  40.    1. It may not work properly with the version of lex you are using.
  41.    Although I tried to make Metre compatible with flex, I have my
  42.    doubts about it.  2. If input buffering is enabled, Metre will
  43.    display the input line along with many error messages.  If this is a
  44.    preprocessed file, the line may be misleading because it may look
  45.    nothing like the original source line after macro replacement has
  46.    taken place.  It, therefore, may be better to just never display the
  47.    input line.  You decide.
  48. */
  49. #ifndef READ_LINE
  50. #define READ_LINE TRUE
  51. #endif
  52.  
  53. /*
  54.    Add defines for new internal error messages here.
  55.    NOTE: 0 is reserved for yyerror() and error messages that YACC generates.
  56. */
  57. #define E_NO_HEAP          1, "Out of heap space"
  58. #define E_LINE_TYPE        2, "Invalid line type"
  59. #define E_CANT_OPEN_LISTING_FILE 3, "Cannot open listing file"
  60.  
  61. /* Add defines for new internal warning messages here. */
  62. #define W_CANNOT_OPEN_FILE 0, "Cannot open %s"
  63.  
  64. /*
  65.    Number of typedef symbols that each typedef-symbol block can hold.  New
  66.    blocks are allocated on an as-needed basis so that the symbol table is not
  67.    a fixed size.
  68. */
  69. #define TYPEDEF_SYMBOLS_PER_BLOCK      1000
  70.  
  71.  
  72. /* Characters used to identify command-line options. */
  73. #define DEFINE_OPT_CHAR       'D'   /* Translate this identifier. */
  74. #define LISTING_OPT_CHAR      'L'   /* Name of listing file to contain output.*/
  75. #define COPY_INPUT_OPT_CHAR   'C'   /* Copy input to standard out. */
  76. #define SUBST_FILE_OPT_CHAR   'S'  /* Substitute file name. */
  77.  
  78. #define OPT_INTRO_CHARS "/-"  /* Command-line option-introduction characters. */
  79.  
  80. /* (Lex's maximum lexeme length--YYLMAX.) */
  81. #define MAX_DECLARATOR_NAME_LEN 100
  82.  
  83. /* typedef for IDENTIFIER array. */
  84. typedef char IDENTIFIER[MAX_DECLARATOR_NAME_LEN];
  85.  
  86.  
  87. /*
  88.    NOTE: External names that are intended to only be used within the parser
  89.    are mangled somewhat by prepending "mtr_" to reduce the possibility of
  90.    collision between names in rules code and parser code.  These #defines
  91.    could all be removed if this is not a concern.
  92. */
  93.  
  94.  
  95. #define mod_decisions   mtr_mod_decisions
  96. #define mod_functions   mtr_mod_functions
  97.  
  98. extern unsigned mod_decisions;
  99. extern unsigned mod_functions;
  100.  
  101.  
  102. #define cmd_line_argc                  mtr_cmd_line_argc
  103. #define cmd_line_argv                  mtr_cmd_line_argv
  104. #define input_file                     mtr_input_file
  105. #define input_file_orig_name           mtr_input_file_orig_name
  106. #define next_cmd_line_file             mtr_next_cmd_line_file
  107. #define next_cmd_line_file_orig_n      mtr_next_cmd_line_file_orig_n
  108. #define column                         mtr_column
  109. #define display_input                  mtr_display_input
  110. #define looking_for_tag                mtr_looking_for_tag
  111.  
  112. extern int cmd_line_argc;
  113. extern char **cmd_line_argv;
  114. extern FILE *yyin;
  115. extern int yylineno;
  116. extern FILE *yyout;
  117. extern char *input_file;
  118. extern char *input_file_orig_name;
  119. extern unsigned next_cmd_line_file;
  120. extern unsigned next_cmd_line_file_orig_n;
  121. extern BOOLEAN display_input;
  122. extern BOOLEAN looking_for_tag;
  123.  
  124.  
  125. #define int_prj      mtr_int_prj
  126. #define int_mod      mtr_int_mod
  127. #define int_lin      mtr_int_lin
  128. #define int_lex      mtr_int_lex
  129.  
  130. extern PRJ int_prj;
  131. extern MOD int_mod;
  132. extern LIN int_lin;
  133. extern LEX int_lex;
  134.  
  135.  
  136. #define get_next_input_file            mtr_get_next_input_file
  137. #define get_next_input_file_orig_name  mtr_get_next_input_file_orig_name
  138. #define typedef_symbol_table_find      mtr_typedef_symbol_table_find
  139. #define init_lex                       mtr_init_lex
  140. #define init_yacc                      mtr_init_yacc
  141. #define fire_prj                       mtr_fire_prj
  142. #define fire_mod                       mtr_fire_mod
  143. #define fire_lin                       mtr_fire_lin
  144. #define fire_lex                       mtr_fire_lex
  145.  
  146. extern char *get_next_input_file(unsigned *p_i);
  147. extern char *get_next_input_file_orig_name(unsigned *p_i);
  148. extern BOOLEAN typedef_symbol_table_find(char *);
  149. extern void init_lex(void);
  150. extern void init_yacc(void);
  151. extern void fire_prj(void);
  152. extern void fire_mod(void);
  153. extern void fire_lin(void);
  154. extern void fire_lex(void);
  155. #ifdef DEBUG_TYPEDEF
  156. extern void typedef_symbol_table_dump(void);
  157. #endif
  158.  
  159. #endif
  160.